package com.bw.lib_log.logger

import android.util.Log
import com.bw.lib_log.LoggerLevel

/**
 * 输出到 网络服务器中
 */
class NetLogger : ILogger {
    private var isDebug = true
    private var TAG = ""
    private var level = LoggerLevel.DEBUG
    private var path = ""
    private var loggerFormat = "===>$TAG %s ---> %s"
    override fun v(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.VERBOSE.value){
            Log.v(TAG,"写到网络服务器中"+String.format(loggerFormat,tag,log))
        }
    }

    override fun d(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.DEBUG.value){
            Log.v(TAG,"写到网络服务器中"+String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.INFO.value){
            Log.v(TAG,"写到网络服务器中"+String.format(loggerFormat,tag,log))
        }
    }

    override fun w(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.WARN.value){
            Log.v(TAG,"写到网络服务器中"+String.format(loggerFormat,tag,log))
        }
    }

    override fun e(tag: String, log: String) {
        if (isDebug && level.value >= LoggerLevel.ERROR.value){
            Log.v(TAG,"写到网络服务器中"+String.format(loggerFormat,tag,log))
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setTag(tag: String) {
        this.TAG = tag
    }

    override fun setSavaUrl(path: String) {
        this.path = path
    }
}
